#include "comm.hpp"

#include <string>

int main()
{
    int msgid = Message_Queue::creat();
    std::cout << "申请消息队列成功" << std::endl;
    
    msg_buf snd;
    snd.mtype = 1;

    pid_t id = getpid();
    char* p = (char*)&id;
    for (int i = 0; i < sizeof(pid_t); ++i)
    {
        snd.mtext[i] = *p;
        ++p;
    }
    Message_Queue::send(msgid, &snd);
    
    while (true)
    {
        std::cout << "client send: ";
        fgets(snd.mtext, 1024, stdin);
        // std::cin >> snd.mtext;
        Message_Queue::send(msgid, &snd);
    }
    
    return 0;
}
